package Tests.UnitTests;

import harima.collision.bodies.Direction;
import harima.collision.bodies.PathNode;

import java.util.Random;

import junit.framework.Assert;
import junit.framework.TestCase;

public class PathNodeFixture extends TestCase{
	
	PathNode node;
	Random random;
	
	public void init()
	{
		random = new Random();
	}
	
	public void test_CanStepAllSteps_StepRequested_Always() throws Exception {
		init();
		
		int steps = random.nextInt(99)+1;
		Direction direction = Direction.Right;
		
		node = new PathNode(direction, steps);
		Assert.assertFalse(node.reachedEnd());
		for(int i=0; i<steps; i++)
		{
			node.step();
		}
		
		Assert.assertTrue(node.reachedEnd());
	}
	
	public void test_RessetsStepCount_ReachedEndRequested_Always() throws Exception {
		init();
		
		int steps = random.nextInt(99)+1;
		Direction direction = Direction.Right;
		
		node = new PathNode(direction, steps);
		Assert.assertFalse(node.reachedEnd());
		for(int i=0; i<steps; i++)
		{
			node.step();
		}
		
		Assert.assertTrue(node.reachedEnd());
		Assert.assertFalse(node.reachedEnd());
		
	}
}
